/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAOHibernate;

import DAO.AnamnesePerguntaDAO;
import entidade.AnamnesePerg;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

/**
 *
 * @author Thais
 */
public class AnamnesePerguntaDAOHibernate implements AnamnesePerguntaDAO {

    @Override
    public List<AnamnesePerg> buscarPorCategoria(String categoria) {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProjetoFinalClientePU");
        EntityManager em = emf.createEntityManager();
        Query buscar = em.createQuery("Select object(c) from AnamnesePerg as c where c.categoria LIKE ?1");
        buscar.setParameter(1, categoria);
        return buscar.getResultList();
    }

    @Override
    public List<AnamnesePerg> listarPerguntas() {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProjetoFinalClientePU");
        EntityManager em = emf.createEntityManager();
        Query buscar = em.createQuery("Select object(c) from AnamnesePerg as c");
        return buscar.getResultList();
    }
}
